import { Application } from 'egg';

export default (app: Application) => {
  const { router, controller } = app;
  const consulRouter = router.namespace('/consul');
  const ipAuthMiddleware = app.middleware.ipAuth(app.config.ipAuth);

  // consul健康检查
  consulRouter.get('/health/check', controller.consul.healthCheck);

  // 注册
  consulRouter.get('/register', ipAuthMiddleware, controller.consul.register);

  // 取消注册
  consulRouter.get('/deregister', ipAuthMiddleware, controller.consul.deregister);
};
